<template>
    <section>
        <el-col :span="24">
            <el-radio-group v-model="form.type" size="mini">
                <el-radio-button :label=0>普通单张开票</el-radio-button>
                <el-radio-button :label=1>多订单合一开票</el-radio-button>
            </el-radio-group>
            <el-form inline>
                <el-form-item>
                    <el-select v-model="form.sellerid" placeholder="开具发票的店铺" clearable size="small" style="width: 150px;">
                        <el-option v-for="(item, index) in shops" :key="index" :label="item.sellertitle" :value="item.sellerid"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-input size="small" v-model.trim="form.sourceid" placeholder="订单号, 多订单请用“逗号”隔开" style="width: 250px;" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-select v-model="form.status" placeholder="任务状态" size="small" style="width: 110px" clearable>
                        <el-option :value=0 label="待处理"></el-option>
                        <el-option :value=1 label="已完成"></el-option>
                        <el-option :value=2 label="处理中"></el-option>
                        <el-option :value=3 label="暂停中"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-select v-model="form.invoicing_status" placeholder="开票状态" size="small" style="width: 150px" multiple collapse-tags clearable>
                        <el-option :value=0 label="未开票"></el-option>
                        <el-option :value=1 label="已开票"></el-option>
                        <el-option :value=2 label="开票失败"></el-option>
                        <el-option :value=3 label="申请冲红"></el-option>
                        <el-option :value=4 label="已冲红"></el-option>
                        <el-option :value=5 label="冲红失败"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-popover placement="bottom" width="450" trigger="click">
                        <el-form label-width="80px" label-position="left">
                            <el-form-item label="买家昵称">
                                <el-input size="small" v-model.trim="form.buyername" placeholder="买家昵称" style="width: 80%;" clearable></el-input>
                            </el-form-item>
                            <el-form-item label="抬头">
                                <el-input size="small" v-model.trim="form.invoice_header" placeholder="抬头" style="width: 80%;" clearable></el-input>
                            </el-form-item>
                            <el-form-item label="税号">
                                <el-input size="small" v-model.trim="form.invoicing_number" placeholder="税号" style="width: 80%;" clearable></el-input>
                            </el-form-item>
                            <el-form-item label="开票日期">
                                <el-date-picker value-format="yyyy-MM-dd" v-model="form.kai_createtime" type="daterange" size="small" style="width: 80%"
                                                range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                            </el-form-item>
                        </el-form>
                        <el-button slot="reference" size="small" type="warning" plain>更多</el-button>
                    </el-popover>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" class="el-icon-search" @click="searchBtn" size="small" :loading="btnLoading">查询</el-button>
                </el-form-item>
            </el-form>
        </el-col>
        <el-col :span="24">
            <el-table :data="data" style="width: 100%" :max-height="tableHeight" v-loading="loading" size="small" stripe>
                <el-table-column label="订单号" align="center" prop="sourceid" width="170" fixed></el-table-column>
                <el-table-column label="订单状态" align="center" prop="order_status" width="100"></el-table-column>
                <el-table-column label="任务状态" align="center" prop="status" width="100">
                    <template slot-scope="{ row }">
                        <el-tag v-if="row.status == 0" size="mini" type="info">待处理</el-tag>
                        <el-tag v-if="row.status == 1" size="mini" type="success">已完成</el-tag>
                        <el-tag v-if="row.status == 2" size="mini" type="warning">处理中</el-tag>
                        <el-tag v-if="row.status == 3" size="mini" type="danger">暂停中</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="是否需开票" align="center" prop="hongchong_status" width="100">
                    <template slot-scope="{ row }">
                        <el-tag v-if="row.hongchong_status == 1" size="mini" type="info">无需开票</el-tag>
                        <el-tag v-if="row.hongchong_status == 2" size="mini">需开票</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="后台发票状态" align="center" prop="invoicing_status" width="100">
                    <template slot-scope="{ row }">
                        <el-tag v-if="row.invoicing_status == 0" size="mini" type="info">未开票</el-tag>
                        <el-tag v-if="row.invoicing_status == 1" size="mini" type="success">已开票</el-tag>
                        <el-popover trigger="hover" v-if="row.invoicing_status == 2" placement="top">
                            <p>{{ row.err_msg }}</p>
                            <el-tag slot="reference" size="mini" type="danger">开票失败</el-tag>
                        </el-popover>
                        <el-tag v-if="row.invoicing_status == 3" size="mini" type="warning">申请冲红</el-tag>
                        <el-tag v-if="row.invoicing_status == 4" size="mini" type="success">冲红成功</el-tag>
                        <el-tag v-if="row.invoicing_status == 5" size="mini" type="danger">冲红失败</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="发票类型" align="center" prop="invoice_headerid" width="100">
                    <template slot-scope="{ row }">
                        {{ row.invoice_headerid == 900 ? "个人" : "公司" }}
                    </template>
                </el-table-column>
                <el-table-column label="多订单合一标识码" align="center" prop="merge_tag" width="80" v-if="form.type == 1"></el-table-column>
                <el-table-column label="开票信息" align="center">
                    <el-table-column label="抬头/税号" align="center" width="200">
                        <template slot-scope="{ row }">
                            {{ row.invoice_header || "--" }} /
                            {{ row.invoicing_number || "--" }}
                        </template>
                    </el-table-column>
                    <el-table-column label="地址/电话" align="center" width="200">
                        <template slot-scope="{ row }">
                            {{ row.opening_bank_address || "--" }} /
                            {{ row.opening_bank_tel || "--" }}
                        </template>
                    </el-table-column>
                    <el-table-column label="开户行/账号" align="center" width="200">
                        <template slot-scope="{ row }">
                            {{ row.opening_bank || "--" }} /
                            {{ row.opening_bank_number || "--" }}
                        </template>
                    </el-table-column>
                    <el-table-column label="客服备注" align="center" prop="notes" width="100" show-overflow-tooltip></el-table-column>
                </el-table-column>
                <el-table-column label="电子邮箱" align="center" prop="email" width="160"></el-table-column>
                <el-table-column label="店铺" align="center" prop="sellerid" width="140">
                    <template slot-scope="{ row }">
                        {{ row.sellerid | filterShop(shops) }}
                    </template>
                </el-table-column>
                <el-table-column label="买家昵称" align="center" prop="buyername" show-overflow-tooltip></el-table-column>
                <el-table-column label="实付金额" align="center" prop="pay_amount"></el-table-column>
                <el-table-column label="开票商品" align="center" width="900">
                    <template slot-scope="{ row }">
                        <el-table border :data="row.order_detail" size="mini" :header-cell-style="{ background: '#F3F4F7', color: '#555' }">
                            <el-table-column label="子订单号" align="center" width="160" prop="son_order_no"></el-table-column>
                            <el-table-column label="商品标题" align="center" prop="product_name" show-overflow-tooltip></el-table-column>
                            <el-table-column label="购买数量" align="center" prop="num" width="100"></el-table-column>
                            <el-table-column label="子订单号实付金额" align="center" prop="pay_amount" width="120"></el-table-column>
                            <el-table-column label="货品编号" align="center" prop="sku_code" width="120"></el-table-column>
                        </el-table>
                    </template>
                </el-table-column>
                <el-table-column label="创建人" align="center" prop="adduserid" width="100"></el-table-column>
                <el-table-column label="执行人" align="center" prop="douserid" width="100"></el-table-column>
                <el-table-column label="创建时间（班牛）" align="center" prop="addtime" width="150"></el-table-column>
                <el-table-column label="修改时间（班牛）" align="center" prop="updatetime" width="150"></el-table-column>
                <el-table-column label="开票时间" align="center" prop="kai_createtime" width="150"></el-table-column>
                <el-table-column label="同步时间" align="center" prop="createtime" width="150"></el-table-column>
                <el-table-column label="操作" align="center" fixed="right" width="140">
                    <template slot-scope="{ row }">
                        <el-button type="text" size="small" @click="detailBtn(row.sourceid)" :disabled="!row.sourceid">详情</el-button>
                        &nbsp;
                        <el-dropdown trigger="hover" style="font-size: 12px;" @command="actionBtn($event, row)">
                            <span style="cursor: pointer;color: #409EFF;">
                                更多操作<i class="el-icon-arrow-down el-icon--right"></i>
                            </span>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item command="KPIF" icon="el-icon-document" :disabled="!(row.hongchong_status==2&&(row.invoicing_status == 3||row.invoicing_status == 5))">
                                    新开票信息
                                </el-dropdown-item>
                                <el-dropdown-item v-if="form.type==0" command="EDIT" icon="el-icon-edit" :disabled="!(row.hongchong_status==2 &&
                                    ['0', '2', '4'].includes(row.invoicing_status))">
                                    修改信息
                                </el-dropdown-item>
                                <el-dropdown-item v-if="form.type==0" command="KP" icon="el-icon-document-add" :disabled="!(row.hongchong_status==1&&row.invoicing_status == 4)">
                                    再次申请开票
                                </el-dropdown-item>
                                <el-dropdown-item v-if="form.type==0" command="CHSQ" icon="el-icon-document-add" :disabled="!(row.hongchong_status==2&&row.invoicing_status == 1)">
                                    发起冲红申请
                                </el-dropdown-item>
                                <el-dropdown-item command="DOWN" icon="el-icon-download" :disabled="!(row.invoiceserialnum &&row.invoicing_status != 0 &&row.invoicing_status != 2)">
                                    下载发票
                                </el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </template>
                </el-table-column>
            </el-table>
            <!--翻页栏-->
            <div style="margin-top: 4px;overflow: hidden;">
                <el-button v-if="form.type==0" plain type="warning" size="mini" @click="openKpsqBtn">申请多订单合一开票</el-button>
                <el-button v-if="form.type==1" plain type="danger" size="mini" @click="openMoreBtn(2, '发起冲红申请')">发起冲红申请</el-button>
                <el-button v-if="form.type==1" plain type="primary" size="mini" @click="openMoreBtn(1, '修改开票信息')">修改开票信息</el-button>
                <el-button v-if="form.type==1" plain type="warning" size="mini" @click="openMoreBtn(3, '取消多合一开票')">取消多合一开票</el-button>
                <el-button v-if="form.type==1" plain size="mini" @click="openMoreBtn(4, '再次申请开票')">再次申请开票</el-button>

                <Page style="float: right;" :total="total" :current="page" :page-size="limit" show-total @on-change="pageChange"></Page>
            </div>
        </el-col>

        <!--详情-->
        <el-drawer title="详情" :visible.sync="detailVisible" size="1200px" direction="rtl" :wrapperClosable="false" :before-close="closeBtn">
            <el-row style="overflow-y:auto;padding: 0 20px;" :style="{'height': drawerTableHeight}">
                <el-tag size="small" v-if="detail.order_status">{{ detail.order_status }}</el-tag>
                <el-form inline label-width="110px" label-position="left">
                    <el-form-item label="任务状态：">
                        <div class="detail_con">
                            <el-tag v-if="detail.status == 0" size="mini" type="info">待处理</el-tag>
                            <el-tag v-if="detail.status == 1" size="mini" type="success">已完成</el-tag>
                            <el-tag v-if="detail.status == 2" size="mini" type="warning">处理中</el-tag>
                            <el-tag v-if="detail.status == 3" size="mini" type="danger">暂停中</el-tag>
                        </div>
                    </el-form-item>
                    <el-form-item label="是否需要开票：">
                        <div class="detail_con">
                            <el-tag v-if="detail.hongchong_status == 1" size="mini" type="info">无需开票</el-tag>
                            <el-tag v-if="detail.hongchong_status == 2" size="mini">需开票</el-tag>
                        </div>
                    </el-form-item>
                    <el-form-item label="后台发票状态：">
                        <div class="detail_con">
                            <el-tag v-if="detail.invoicing_status == 0" size="mini" type="info">未开票</el-tag>
                            <el-tag v-if="detail.invoicing_status == 1" size="mini" type="success">已开票</el-tag>
                            <el-tag v-if="detail.invoicing_status == 2" size="mini" type="danger">开票失败</el-tag>
                            <el-tag v-if="detail.invoicing_status == 3" size="mini" type="warning">申请冲红</el-tag>
                            <el-tag v-if="detail.invoicing_status == 4" size="mini" type="success">冲红成功</el-tag>
                            <el-tag v-if="detail.invoicing_status == 5" size="mini" type="danger">冲红失败</el-tag>
                        </div>
                    </el-form-item>
                    <el-form-item label="抬头：">
                        <div class="detail_con">{{ detail.invoice_header || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="税号：">
                        <div class="detail_con">{{ detail.invoicing_number || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="地址：">
                        <div class="detail_con">{{ detail.opening_bank_address || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="开户行：">
                        <div class="detail_con">{{ detail.opening_bank || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="开户账号：">
                        <div class="detail_con">{{ detail.opening_bank_number || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="电子邮箱：">
                        <div class="detail_con">{{ detail.email || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="店铺：">
                        <div class="detail_con">{{ detail.sellerid | filterShop(shops) }}</div>
                    </el-form-item>
                    <el-form-item label="订单号：">
                        <div class="detail_con">{{ detail.sourceid || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="买家昵称：">
                        <div class="detail_con">{{ detail.buyername || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="创建人：">
                        <div class="detail_con">{{ detail.adduserid || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="执行人：">
                        <div class="detail_con">{{ detail.douserid || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="创建时间：">
                        <div class="detail_con">{{ detail.addtime || "--" }}</div>
                    </el-form-item>
                    <el-form-item label="客服备注：">
                        <div class="detail_con">{{ detail.notes || "--" }}</div>
                    </el-form-item>
                </el-form>
                <div>
                    <svg t="1717659283335" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9445" width="18" height="18"><path d="M407.466667 477.866667h-277.333334C93.866667 477.866667 64 448 64 409.6v-277.333333c0-36.266667 29.866667-66.133333 66.133333-66.133334h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133334v277.333333c2.133333 38.4-27.733333 68.266667-66.133333 68.266667zM132.266667 108.8c-12.8 0-25.6 10.666667-25.6 25.6v277.333333c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333333c0-12.8-10.666667-25.6-25.6-25.6h-277.333333zM407.466667 960h-277.333334C93.866667 960 64 930.133333 64 893.866667v-277.333334c0-36.266667 29.866667-66.133333 66.133333-66.133333h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM132.266667 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z m618.666666-110.933333c-17.066667 0-34.133333-6.4-46.933333-19.2L563.2 320c-12.8-12.8-19.2-29.866667-19.2-46.933333s6.4-34.133333 19.2-46.933334L704 83.2c12.8-12.8 29.866667-19.2 46.933333-19.2 17.066667 0 34.133333 6.4 46.933334 19.2l140.8 140.8c12.8 12.8 19.2 29.866667 19.2 46.933333 0 17.066667-6.4 34.133333-19.2 46.933334l-138.666667 142.933333c-12.8 12.8-29.866667 19.2-49.066667 19.2z m0-373.333333c-6.4 0-12.8 2.133333-17.066666 6.4l-140.8 140.8c-4.266667 4.266667-6.4 10.666667-6.4 17.066666 0 6.4 2.133333 12.8 6.4 17.066667l140.8 140.8c4.266667 4.266667 10.666667 6.4 17.066666 6.4 6.4 0 12.8-2.133333 17.066667-6.4l140.8-140.8c4.266667-4.266667 6.4-10.666667 6.4-17.066667 0-6.4-2.133333-12.8-6.4-17.066666L768 113.066667c-4.266667-4.266667-8.533333-6.4-17.066667-6.4z m138.666667 853.333333h-277.333333c-36.266667 0-66.133333-29.866667-66.133334-66.133333v-277.333334c0-36.266667 29.866667-66.133333 66.133334-66.133333h277.333333c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM614.4 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z" fill="#1E87EB" p-id="9446"></path></svg>
                    <span style="font-size: 16px;font-weight: bold;vertical-align: bottom;margin-left: 4px;">开票商品</span>
                </div>
                <el-table border :data="detail.order_detail" size="mini">
                    <el-table-column label="子订单号" align="center" width="180" prop="son_order_no"></el-table-column>
                    <el-table-column label="商品标题" align="center" prop="product_name"></el-table-column>
                    <el-table-column label="购买数量" align="center" prop="num" width="90"></el-table-column>
                    <el-table-column label="子订单号实付金额" align="center" prop="pay_amount" width="150"></el-table-column>
                    <el-table-column label="货品编号" align="center" prop="sku_code" width="150"></el-table-column>
                </el-table>
                <div style="margin-top: 10px">
                    <svg t="1717659283335" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9445" width="18" height="18"><path d="M407.466667 477.866667h-277.333334C93.866667 477.866667 64 448 64 409.6v-277.333333c0-36.266667 29.866667-66.133333 66.133333-66.133334h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133334v277.333333c2.133333 38.4-27.733333 68.266667-66.133333 68.266667zM132.266667 108.8c-12.8 0-25.6 10.666667-25.6 25.6v277.333333c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333333c0-12.8-10.666667-25.6-25.6-25.6h-277.333333zM407.466667 960h-277.333334C93.866667 960 64 930.133333 64 893.866667v-277.333334c0-36.266667 29.866667-66.133333 66.133333-66.133333h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM132.266667 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z m618.666666-110.933333c-17.066667 0-34.133333-6.4-46.933333-19.2L563.2 320c-12.8-12.8-19.2-29.866667-19.2-46.933333s6.4-34.133333 19.2-46.933334L704 83.2c12.8-12.8 29.866667-19.2 46.933333-19.2 17.066667 0 34.133333 6.4 46.933334 19.2l140.8 140.8c12.8 12.8 19.2 29.866667 19.2 46.933333 0 17.066667-6.4 34.133333-19.2 46.933334l-138.666667 142.933333c-12.8 12.8-29.866667 19.2-49.066667 19.2z m0-373.333333c-6.4 0-12.8 2.133333-17.066666 6.4l-140.8 140.8c-4.266667 4.266667-6.4 10.666667-6.4 17.066666 0 6.4 2.133333 12.8 6.4 17.066667l140.8 140.8c4.266667 4.266667 10.666667 6.4 17.066666 6.4 6.4 0 12.8-2.133333 17.066667-6.4l140.8-140.8c4.266667-4.266667 6.4-10.666667 6.4-17.066667 0-6.4-2.133333-12.8-6.4-17.066666L768 113.066667c-4.266667-4.266667-8.533333-6.4-17.066667-6.4z m138.666667 853.333333h-277.333333c-36.266667 0-66.133333-29.866667-66.133334-66.133333v-277.333334c0-36.266667 29.866667-66.133333 66.133334-66.133333h277.333333c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM614.4 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z" fill="#1E87EB" p-id="9446"></path></svg>
                    <span style="font-size: 16px;font-weight: bold;vertical-align: bottom;margin-left: 4px;">开票信息历史</span>
                </div>
                <el-table border :data="detailLog" size="mini">
                    <el-table-column label="发票信息更新时间" align="center" width="160" prop="createtime"></el-table-column>
                    <el-table-column label="类型" align="center" prop="type" width="80">
                        <template slot-scope="{ row }">
                            {{ row.type == 1 ? "开票" : "冲红" }}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作人" align="center" prop="operator_user"></el-table-column>
                    <el-table-column label="发票类型" align="center" prop="invoice_headerid" width="80">
                        <template slot-scope="{ row }">
                            {{ row.invoice_headerid == 900 ? "个人" : "公司" }}
                        </template>
                    </el-table-column>
                    <el-table-column label="发票" align="center" prop="c_url" width="80">
                        <template slot-scope="{ row }">
                            <el-link type="primary" :href="row.c_url" target="_blank" v-if="row.c_url">点击查看</el-link>
                        </template>
                    </el-table-column>
                    <el-table-column label="开票信息" align="center">
                        <el-table-column label="抬头/税号" align="center" width="250">
                            <template slot-scope="{ row }">
                                {{ row.invoice_header || "--" }} /
                                {{ row.invoicing_number || "--" }}
                            </template>
                        </el-table-column>
                        <el-table-column label="地址/电话" align="center" width="250">
                            <template slot-scope="{ row }">
                                {{ row.opening_bank_address || "--" }} /
                                {{ row.opening_bank_tel || "--" }}
                            </template>
                        </el-table-column>
                        <el-table-column label="开户行/账号" align="center" width="250">
                            <template slot-scope="{ row }">
                                {{ row.opening_bank || "--" }} /
                                {{ row.opening_bank_number || "--" }}
                            </template>
                        </el-table-column>
                        <el-table-column label="客服备注" align="center" prop="notes" width="100"></el-table-column>
                    </el-table-column>
                    <el-table-column label="邮箱" align="center" prop="email"></el-table-column>
                    <el-table-column label="开票商品" align="center" width="1000">
                        <template slot-scope="{ row }">
                            <el-table border :data="row.order_detail" size="mini" :max-height="300">
                                <el-table-column label="子订单号" align="center" width="180" prop="son_order_no"></el-table-column>
                                <el-table-column label="商品标题" align="center" prop="product_name"></el-table-column>
                                <el-table-column label="购买数量" align="center" prop="num" width="90"></el-table-column>
                                <el-table-column label="子订单号实付金额" align="center" prop="pay_amount" width="150"></el-table-column>
                                <el-table-column label="货品编号" align="center" prop="sku_code" width="150"></el-table-column>
                            </el-table>
                        </template>
                    </el-table-column>
                </el-table>
            </el-row>
        </el-drawer>

        <!--新开票信息、修改信息、再次申请开票-->
        <el-drawer :title="commandTitle" :visible.sync="detailNewVisible" size="1200px" direction="rtl" :wrapperClosable="false" :before-close="closeBtn">
            <el-row style="overflow-y:auto;padding: 0 20px;" :style="{'height': drawerTableHeight}">
                <el-radio-group v-model="detailNew.invoice_headerid" size="small">
                    <el-radio label="900" border>个人电子发票</el-radio>
                    <el-radio label="18661" border>公司电子发票</el-radio>
                </el-radio-group>
                <el-form inline label-position="right" label-width="80px">
                    <el-form-item label="订单号:">
                        <div class="detail_ch_con">{{detailNew.sourceid}}</div>
                    </el-form-item>
                    <el-form-item label="店铺:">
                        <div class="detail_ch_con">{{detailNew.sellerid | filterShop(shops)}}</div>
                    </el-form-item>
                    <el-form-item label="抬头:">
                        <div class="detail_ch_con">
                            <el-input size="small" v-model.trim="detailNew.invoice_header"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="邮箱:">
                        <div class="detail_ch_con">
                            <el-input size="small" v-model.trim="detailNew.email"></el-input>
                        </div>
                    </el-form-item>
                    <template v-if="detailNew.invoice_headerid == 18661">
                        <el-form-item label="税号:">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="detailNew.invoicing_number"></el-input>
                            </div>
                        </el-form-item>
                        <el-form-item label="开户行:">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="detailNew.opening_bank"></el-input>
                            </div>
                        </el-form-item>
                        <el-form-item label="开户行号:">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="detailNew.opening_bank_number"></el-input>
                            </div>
                        </el-form-item>
                        <el-form-item label="地址:">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="detailNew.opening_bank_address"></el-input>
                            </div>
                        </el-form-item>
                        <el-form-item label="电话:">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="detailNew.opening_bank_tel"></el-input>
                            </div>
                        </el-form-item>
                        <el-form-item label="客服备注:">
                            <div class="detail_ch_con">
                                <el-input type="textarea" autosize size="small" v-model.trim="detailNew.notes"></el-input>
                            </div>
                        </el-form-item>
                    </template>
                </el-form>
                <div style="margin-top: 10px">
                    <svg t="1717659283335" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9445" width="18" height="18"><path d="M407.466667 477.866667h-277.333334C93.866667 477.866667 64 448 64 409.6v-277.333333c0-36.266667 29.866667-66.133333 66.133333-66.133334h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133334v277.333333c2.133333 38.4-27.733333 68.266667-66.133333 68.266667zM132.266667 108.8c-12.8 0-25.6 10.666667-25.6 25.6v277.333333c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333333c0-12.8-10.666667-25.6-25.6-25.6h-277.333333zM407.466667 960h-277.333334C93.866667 960 64 930.133333 64 893.866667v-277.333334c0-36.266667 29.866667-66.133333 66.133333-66.133333h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM132.266667 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z m618.666666-110.933333c-17.066667 0-34.133333-6.4-46.933333-19.2L563.2 320c-12.8-12.8-19.2-29.866667-19.2-46.933333s6.4-34.133333 19.2-46.933334L704 83.2c12.8-12.8 29.866667-19.2 46.933333-19.2 17.066667 0 34.133333 6.4 46.933334 19.2l140.8 140.8c12.8 12.8 19.2 29.866667 19.2 46.933333 0 17.066667-6.4 34.133333-19.2 46.933334l-138.666667 142.933333c-12.8 12.8-29.866667 19.2-49.066667 19.2z m0-373.333333c-6.4 0-12.8 2.133333-17.066666 6.4l-140.8 140.8c-4.266667 4.266667-6.4 10.666667-6.4 17.066666 0 6.4 2.133333 12.8 6.4 17.066667l140.8 140.8c4.266667 4.266667 10.666667 6.4 17.066666 6.4 6.4 0 12.8-2.133333 17.066667-6.4l140.8-140.8c4.266667-4.266667 6.4-10.666667 6.4-17.066667 0-6.4-2.133333-12.8-6.4-17.066666L768 113.066667c-4.266667-4.266667-8.533333-6.4-17.066667-6.4z m138.666667 853.333333h-277.333333c-36.266667 0-66.133333-29.866667-66.133334-66.133333v-277.333334c0-36.266667 29.866667-66.133333 66.133334-66.133333h277.333333c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM614.4 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z" fill="#1E87EB" p-id="9446"></path></svg>
                    <span style="font-size: 16px;font-weight: bold;vertical-align: bottom;margin-left: 4px;">开票商品</span>
                </div>
                <el-table border :data="detailNew.order_detail" size="mini">
                    <el-table-column label="子订单号" align="center" width="180" prop="son_order_no"></el-table-column>
                    <el-table-column label="商品标题" align="center" prop="product_name"></el-table-column>
                    <el-table-column label="购买数量" align="center" prop="num" width="100"></el-table-column>
                    <el-table-column label="子订单号实付金额" align="center" prop="pay_amount" width="120">
                        <template slot-scope="{ row }">
                            <el-input v-model.trim="row.pay_amount" size="mini" v-if="commandType != 'KPIF'"></el-input>
                            <div v-else>{{ row.pay_amount }}</div>
                        </template>
                    </el-table-column>
                    <el-table-column label="货品编号" align="center" prop="sku_code" width="120"></el-table-column>
                </el-table>
                <div style="float:right;margin-top:10px;font-size:16px;color:red;font-weight:bold">合计：{{amountTotal}}</div>
            </el-row>
            <div v-if="commandType != 'KPIF'" style="width: 100%;position: absolute;bottom: 10px;padding: 8px;border-top: 1px #ebeef5 solid;">
                <el-button @click="closeBtn">取 消</el-button>
                <el-button type="primary" @click="updateBtn" :loading="saveLoading">{{ saveLoading ? '提交中 ...' : '确 认' }}</el-button>
            </div>
        </el-drawer>

        <!--发起冲红申请-->
        <el-drawer title="发起冲红申请" :visible.sync="chsqVisible" size="1200px" direction="rtl" :wrapperClosable="false" :before-close="closeBtn">
            <el-row style="overflow-y:auto;padding: 0 20px;" :style="{'height': drawerTableHeight}">
                <div>
                    <el-radio-group v-model="chsqForm.hongchong_status" size="mini">
                        <el-radio label="1" border>只冲红不开票</el-radio>
                        <el-radio label="2" border>冲红再开票</el-radio>
                    </el-radio-group>
                </div>
                <div v-if="chsqForm.hongchong_status == 2" style="margin-top: 10px;">
                    <el-radio-group v-model="chsqForm.invoice_headerid" size="mini">
                        <el-radio label="900" border>个人电子发票</el-radio>
                        <el-radio label="18661" border>公司电子发票</el-radio>
                    </el-radio-group>
                </div>
                <el-form :model="chsqForm" :rules="rules"  inline label-position="left" label-width="75px">
                    <el-form-item label="订单号:">
                        <div class="detail_ch_con">{{chsqForm.sourceid}}</div>
                    </el-form-item>
                    <el-form-item label="店铺:">
                        <div class="detail_ch_con">{{chsqForm.sellerid | filterShop(shops)}}</div>
                    </el-form-item>
                    <template v-if="chsqForm.hongchong_status==2">
                        <el-form-item label="抬头:" prop="invoice_header">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="chsqForm.invoice_header"></el-input>
                            </div>
                        </el-form-item>
                        <el-form-item label="邮箱:" prop="email">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="chsqForm.email"></el-input>
                            </div>
                        </el-form-item>
                        <template v-if="chsqForm.invoice_headerid=='18661'">
                            <el-form-item label="税号:" prop="invoicing_number">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="chsqForm.invoicing_number"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="开户行:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="chsqForm.opening_bank"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="开户行号:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="chsqForm.opening_bank_number"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="地址:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="chsqForm.opening_bank_address"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="电话:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="chsqForm.opening_bank_tel"></el-input>
                                </div>
                            </el-form-item>
                        </template>
                        <el-form-item label="客服备注:">
                            <div class="detail_ch_con">
                                <el-input type="textarea" size="small" v-model.trim="chsqForm.notes"></el-input>
                            </div>
                        </el-form-item>
                    </template>
                </el-form>
                <div style="margin-top: 10px">
                    <svg t="1717659283335" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9445" width="18" height="18"><path d="M407.466667 477.866667h-277.333334C93.866667 477.866667 64 448 64 409.6v-277.333333c0-36.266667 29.866667-66.133333 66.133333-66.133334h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133334v277.333333c2.133333 38.4-27.733333 68.266667-66.133333 68.266667zM132.266667 108.8c-12.8 0-25.6 10.666667-25.6 25.6v277.333333c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333333c0-12.8-10.666667-25.6-25.6-25.6h-277.333333zM407.466667 960h-277.333334C93.866667 960 64 930.133333 64 893.866667v-277.333334c0-36.266667 29.866667-66.133333 66.133333-66.133333h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM132.266667 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z m618.666666-110.933333c-17.066667 0-34.133333-6.4-46.933333-19.2L563.2 320c-12.8-12.8-19.2-29.866667-19.2-46.933333s6.4-34.133333 19.2-46.933334L704 83.2c12.8-12.8 29.866667-19.2 46.933333-19.2 17.066667 0 34.133333 6.4 46.933334 19.2l140.8 140.8c12.8 12.8 19.2 29.866667 19.2 46.933333 0 17.066667-6.4 34.133333-19.2 46.933334l-138.666667 142.933333c-12.8 12.8-29.866667 19.2-49.066667 19.2z m0-373.333333c-6.4 0-12.8 2.133333-17.066666 6.4l-140.8 140.8c-4.266667 4.266667-6.4 10.666667-6.4 17.066666 0 6.4 2.133333 12.8 6.4 17.066667l140.8 140.8c4.266667 4.266667 10.666667 6.4 17.066666 6.4 6.4 0 12.8-2.133333 17.066667-6.4l140.8-140.8c4.266667-4.266667 6.4-10.666667 6.4-17.066667 0-6.4-2.133333-12.8-6.4-17.066666L768 113.066667c-4.266667-4.266667-8.533333-6.4-17.066667-6.4z m138.666667 853.333333h-277.333333c-36.266667 0-66.133333-29.866667-66.133334-66.133333v-277.333334c0-36.266667 29.866667-66.133333 66.133334-66.133333h277.333333c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM614.4 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z" fill="#1E87EB" p-id="9446"></path></svg>
                    <span style="font-size: 16px;font-weight: bold;vertical-align: bottom;margin-left: 4px;">开票商品</span>
                </div>
                <el-table border :data="chsqForm.order_detail" size="mini">
                    <el-table-column label="子订单号" align="center" width="180" prop="son_order_no"></el-table-column>
                    <el-table-column label="商品标题" align="center" prop="product_name"></el-table-column>
                    <el-table-column label="购买数量" align="center" prop="num" width="100"></el-table-column>
                    <el-table-column label="子订单号实付金额" align="center" prop="pay_amount" width="120">
                        <template slot-scope="{row}">
                            <el-input v-model.trim="row.pay_amount" size="mini" v-if="chsqForm.hongchong_status == 2"></el-input>
                            <div v-else>{{ row.pay_amount }}</div>
                        </template>
                    </el-table-column>
                    <el-table-column label="货品编号" align="center" prop="sku_code" width="120"></el-table-column>
                </el-table>
                <div style="float:right;margin-top:10px;font-size:16px;color:red;font-weight:bold">合计：{{amountTotal}}</div>
            </el-row>
            <div style="width: 100%;position: absolute;bottom: 10px;padding: 8px;border-top: 1px #ebeef5 solid;">
                <el-button @click="closeBtn">取 消</el-button>
                <el-button type="primary" @click="applyCHBtn" :loading="saveLoading">{{ saveLoading ? '提交中 ...' : '确 认' }}</el-button>
            </div>
        </el-drawer>

        <!--2发起冲红申请、1修改发票信息、3取消多合一开票、4再次申请开票--多开-->
        <el-drawer :title="commandTitle" :visible.sync="moreVisible" size="1200px" direction="rtl" :wrapperClosable="false" :before-close="closeBtn">
            <template v-if="step==1">
                <chsq-more v-if="moreVisible" @selectHander="moreSelectBtn" :type="commandType" :shops="shops"></chsq-more>
                <div style="width: 100%;position: absolute;bottom: 10px;padding: 8px;border-top: 1px #ebeef5 solid;">
                    <el-button v-if="commandType==3" @click="cancelMoreBtn" :loading="saveLoading" type="primary" :disabled="moreSelectData==0">确 定</el-button>
                    <el-button v-else @click="stepBtn" :disabled="moreSelectData.length==0" :loading="stepLoading" type="primary">下一步</el-button>
                </div>
            </template>
            <template v-else>
                <el-row style="overflow-y:auto;padding: 0 20px;" :style="{'height': drawerTableHeight}">
                    <div v-if="commandType==2">
                        <el-radio-group v-model="chsqForm.hongchong_status" size="mini">
                            <el-radio label="1" border>只冲红不开票</el-radio>
                            <el-radio label="2" border>冲红再开票</el-radio>
                        </el-radio-group>
                    </div>
                    <div v-if="(commandType==2 && chsqForm.hongchong_status == 2) || [1, 4].includes(commandType)" style="margin-top: 10px;">
                        <el-radio-group v-model="chsqForm.invoice_headerid" size="mini">
                            <el-radio label="900" border>个人电子发票</el-radio>
                            <el-radio label="18661" border>公司电子发票</el-radio>
                        </el-radio-group>
                    </div>
                    <el-form inline :rules="rules" label-position="right" label-width="90px">
                        <el-form-item label="订单号:">
                            <div class="detail_ch_con" v-if="chsqForm.sourceIds" style="color: #57a3f3">
                                <el-popover trigger="click" placement="bottom-start">
                                    <div v-html="chsqForm.sourceIds_dom"></div>
                                    <a slot="reference">{{chsqForm.sourceIds.join(",")}}</a>
                                </el-popover>
                            </div>
                        </el-form-item>
                        <template v-if="chsqForm.hongchong_status == 2">
                            <el-form-item label="抬头:" prop="invoice_header">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="chsqForm.invoice_header"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="邮箱:" prop="email">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="chsqForm.email"></el-input>
                                </div>
                            </el-form-item>
                            <template v-if="chsqForm.invoice_headerid == 18661">
                                <el-form-item label="税号:" prop="invoicing_number">
                                    <div class="detail_ch_con">
                                        <el-input size="small" v-model.trim="chsqForm.invoicing_number"></el-input>
                                    </div>
                                </el-form-item>
                                <el-form-item label="开户行:">
                                    <div class="detail_ch_con">
                                        <el-input size="small" v-model.trim="chsqForm.opening_bank"></el-input>
                                    </div>
                                </el-form-item>
                                <el-form-item label="开户行号:">
                                    <div class="detail_ch_con">
                                        <el-input size="small" v-model.trim="chsqForm.opening_bank_number"></el-input>
                                    </div>
                                </el-form-item>
                                <el-form-item label="地址:">
                                    <div class="detail_ch_con">
                                        <el-input size="small" v-model.trim="chsqForm.opening_bank_address"></el-input>
                                    </div>
                                </el-form-item>
                                <el-form-item label="电话:">
                                    <div class="detail_ch_con">
                                        <el-input size="small" v-model.trim="chsqForm.opening_bank_tel"></el-input>
                                    </div>
                                </el-form-item>
                            </template>
                            <el-form-item label="客服备注:">
                                <div class="detail_ch_con">
                                    <el-input type="textarea" autosize size="small" v-model.trim="chsqForm.notes"></el-input>
                                </div>
                            </el-form-item>
                        </template>
                    </el-form>
                    <div style="margin-top: 10px">
                        <svg t="1717659283335" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9445" width="18" height="18"><path d="M407.466667 477.866667h-277.333334C93.866667 477.866667 64 448 64 409.6v-277.333333c0-36.266667 29.866667-66.133333 66.133333-66.133334h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133334v277.333333c2.133333 38.4-27.733333 68.266667-66.133333 68.266667zM132.266667 108.8c-12.8 0-25.6 10.666667-25.6 25.6v277.333333c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333333c0-12.8-10.666667-25.6-25.6-25.6h-277.333333zM407.466667 960h-277.333334C93.866667 960 64 930.133333 64 893.866667v-277.333334c0-36.266667 29.866667-66.133333 66.133333-66.133333h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM132.266667 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z m618.666666-110.933333c-17.066667 0-34.133333-6.4-46.933333-19.2L563.2 320c-12.8-12.8-19.2-29.866667-19.2-46.933333s6.4-34.133333 19.2-46.933334L704 83.2c12.8-12.8 29.866667-19.2 46.933333-19.2 17.066667 0 34.133333 6.4 46.933334 19.2l140.8 140.8c12.8 12.8 19.2 29.866667 19.2 46.933333 0 17.066667-6.4 34.133333-19.2 46.933334l-138.666667 142.933333c-12.8 12.8-29.866667 19.2-49.066667 19.2z m0-373.333333c-6.4 0-12.8 2.133333-17.066666 6.4l-140.8 140.8c-4.266667 4.266667-6.4 10.666667-6.4 17.066666 0 6.4 2.133333 12.8 6.4 17.066667l140.8 140.8c4.266667 4.266667 10.666667 6.4 17.066666 6.4 6.4 0 12.8-2.133333 17.066667-6.4l140.8-140.8c4.266667-4.266667 6.4-10.666667 6.4-17.066667 0-6.4-2.133333-12.8-6.4-17.066666L768 113.066667c-4.266667-4.266667-8.533333-6.4-17.066667-6.4z m138.666667 853.333333h-277.333333c-36.266667 0-66.133333-29.866667-66.133334-66.133333v-277.333334c0-36.266667 29.866667-66.133333 66.133334-66.133333h277.333333c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM614.4 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z" fill="#1E87EB" p-id="9446"></path></svg>
                        <span style="font-size: 16px;font-weight: bold;vertical-align: bottom;margin-left: 4px;">开票商品</span>
                    </div>
                    <el-table border :data="chsqForm.order_detail" size="mini">
                        <el-table-column label="子订单号" align="center" width="180" prop="son_order_no"></el-table-column>
                        <el-table-column label="商品标题" align="center" prop="product_name"></el-table-column>
                        <el-table-column label="购买数量" align="center" prop="num" width="100"></el-table-column>
                        <el-table-column label="子订单号实付金额" align="center" prop="pay_amount" width="120">
                            <template slot-scope="{row}">
                                <el-input v-model.trim="row.pay_amount" size="mini" v-if="chsqForm.hongchong_status == 2"></el-input>
                                <div v-else>{{ row.pay_amount }}</div>
                            </template>
                        </el-table-column>
                        <el-table-column label="货品编号" align="center" prop="sku_code" width="120"></el-table-column>
                    </el-table>
                    <div style="float:right;margin-top:10px;font-size:16px;color:red;font-weight:bold">合计：{{amountTotal}}</div>
                </el-row>
                <div style="width: 100%;position: absolute;bottom: 10px;padding: 8px;border-top: 1px #ebeef5 solid;">
                    <el-button @click="closeBtn">取 消</el-button>
                    <el-button type="primary" @click="moreSubmitBtn" :loading="saveLoading">{{ saveLoading ? '提交中 ...' : '确 认' }}</el-button>
                </div>
            </template>
        </el-drawer>

        <!--申请多订单合一开票-->
        <el-drawer title="申请多订单合一开票" :visible.sync="kpsqVisible" size="1200px" :wrapperClosable="false" :before-close="closeBtn">
            <template v-if="step==1">
                <kpsq v-if="kpsqVisible" @selectHander="moreSelectBtn" :shops="shops"></kpsq>
                <div style="width: 100%;position: absolute;bottom: 10px;padding: 8px;border-top: 1px #ebeef5 solid;">
                    <el-button @click="kpsqStepBtn" :disabled="moreSelectData.length < 2" :loading="stepLoading" type="primary">下一步</el-button>
                </div>
            </template>
            <template v-else>
                <el-row style="overflow-y:auto;padding: 0 20px;" :style="{'height': drawerTableHeight}">
                    <el-radio-group v-model="kpsqForm.invoice_headerid" size="small">
                        <el-radio label="900" border>个人电子发票</el-radio>
                        <el-radio label="18661" border>公司电子发票</el-radio>
                    </el-radio-group>
                    <el-form inline :rules="rules" label-position="right" label-width="80px">
                        <el-form-item label="订单号:">
                            <div class="detail_ch_con" v-if="kpsqForm.sourceIds" style="color: #57a3f3">
                                <el-popover trigger="click" placement="bottom-start">
                                    <div v-html="kpsqForm.sourceIds_dom"></div>
                                    <a slot="reference">{{kpsqForm.sourceIds.join(",")}}</a>
                                </el-popover>
                            </div>
                        </el-form-item>
                        <el-form-item label="抬头:" prop="invoice_header">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="kpsqForm.invoice_header"></el-input>
                            </div>
                        </el-form-item>
                        <el-form-item label="邮箱:" prop="email">
                            <div class="detail_ch_con">
                                <el-input size="small" v-model.trim="kpsqForm.email"></el-input>
                            </div>
                        </el-form-item>
                        <template v-if="kpsqForm.invoice_headerid == 18661">
                            <el-form-item label="税号:" prop="invoicing_number">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="kpsqForm.invoicing_number"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="开户行:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="kpsqForm.opening_bank"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="开户行号:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="kpsqForm.opening_bank_number"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="地址:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="kpsqForm.opening_bank_address"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="电话:">
                                <div class="detail_ch_con">
                                    <el-input size="small" v-model.trim="kpsqForm.opening_bank_tel"></el-input>
                                </div>
                            </el-form-item>
                        </template>
                        <el-form-item label="客服备注:">
                            <div class="detail_ch_con">
                                <el-input type="textarea" autosize size="small" v-model.trim="kpsqForm.notes"></el-input>
                            </div>
                        </el-form-item>
                    </el-form>
                    <div style="margin-top: 10px">
                        <svg t="1717659283335" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9445" width="18" height="18"><path d="M407.466667 477.866667h-277.333334C93.866667 477.866667 64 448 64 409.6v-277.333333c0-36.266667 29.866667-66.133333 66.133333-66.133334h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133334v277.333333c2.133333 38.4-27.733333 68.266667-66.133333 68.266667zM132.266667 108.8c-12.8 0-25.6 10.666667-25.6 25.6v277.333333c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333333c0-12.8-10.666667-25.6-25.6-25.6h-277.333333zM407.466667 960h-277.333334C93.866667 960 64 930.133333 64 893.866667v-277.333334c0-36.266667 29.866667-66.133333 66.133333-66.133333h277.333334c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM132.266667 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z m618.666666-110.933333c-17.066667 0-34.133333-6.4-46.933333-19.2L563.2 320c-12.8-12.8-19.2-29.866667-19.2-46.933333s6.4-34.133333 19.2-46.933334L704 83.2c12.8-12.8 29.866667-19.2 46.933333-19.2 17.066667 0 34.133333 6.4 46.933334 19.2l140.8 140.8c12.8 12.8 19.2 29.866667 19.2 46.933333 0 17.066667-6.4 34.133333-19.2 46.933334l-138.666667 142.933333c-12.8 12.8-29.866667 19.2-49.066667 19.2z m0-373.333333c-6.4 0-12.8 2.133333-17.066666 6.4l-140.8 140.8c-4.266667 4.266667-6.4 10.666667-6.4 17.066666 0 6.4 2.133333 12.8 6.4 17.066667l140.8 140.8c4.266667 4.266667 10.666667 6.4 17.066666 6.4 6.4 0 12.8-2.133333 17.066667-6.4l140.8-140.8c4.266667-4.266667 6.4-10.666667 6.4-17.066667 0-6.4-2.133333-12.8-6.4-17.066666L768 113.066667c-4.266667-4.266667-8.533333-6.4-17.066667-6.4z m138.666667 853.333333h-277.333333c-36.266667 0-66.133333-29.866667-66.133334-66.133333v-277.333334c0-36.266667 29.866667-66.133333 66.133334-66.133333h277.333333c36.266667 0 66.133333 29.866667 66.133333 66.133333v277.333334c2.133333 36.266667-27.733333 66.133333-66.133333 66.133333zM614.4 590.933333c-12.8 0-25.6 10.666667-25.6 25.6v277.333334c0 12.8 10.666667 25.6 25.6 25.6h277.333333c12.8 0 25.6-10.666667 25.6-25.6v-277.333334c0-12.8-10.666667-25.6-25.6-25.6h-277.333333z" fill="#1E87EB" p-id="9446"></path></svg>
                        <span style="font-size: 16px;font-weight: bold;vertical-align: bottom;margin-left: 4px;">开票商品</span>
                    </div>
                    <el-table border :data="kpsqForm.order_detail" size="mini">
                        <el-table-column label="子订单号" align="center" width="180" prop="son_order_no"></el-table-column>
                        <el-table-column label="商品标题" align="center" prop="product_name"></el-table-column>
                        <el-table-column label="购买数量" align="center" prop="num" width="100"></el-table-column>
                        <el-table-column label="子订单号实付金额" align="center" prop="pay_amount" width="120">
                            <template slot-scope="{row}">
                                <el-input size="mini" v-model.trim="row.pay_amount"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column label="货品编号" align="center" prop="sku_code" width="120"></el-table-column>
                    </el-table>
                    <div style="float:right;margin-top:10px;font-size:16px;color:red;font-weight:bold">合计：{{amountTotal}}</div>
                </el-row>
                <div style="width: 100%;position: absolute;bottom: 10px;padding: 8px;border-top: 1px #ebeef5 solid;">
                    <el-button @click="closeBtn">取 消</el-button>
                    <el-button type="primary" @click="kpsqSubmitBtn" :loading="saveLoading">{{ saveLoading ? '提交中 ...' : '确 认' }}</el-button>
                </div>
            </template>
        </el-drawer>
    </section>
</template>

<script>

import {
    invoiceApplyCH,
    invoiceDetail,
    invoiceNewDetail,
    invoiceList,
    invoiceShops, invoiceSetData, invoiceCHDetail, invoiceCancelMore, invoiceSetMoreData,
} from "@/api/fd/invoice";
import chsqMore from "@/view/cs/components/chsqMore";
import kpsq from "@/view/cs/components/kpsq";

export default {
    name: "cs_invoice",
    components:{
        chsqMore,kpsq
    },
    data() {
        return {
            tableHeight: window.innerHeight - 240,
            selectIndex: 0,
            btnLoading: false,
            loading: false,
            page: 1,
            limit: 20,
            total: 0,
            data: [],
            user: {},
            nodeActions: [],

            shops: [],
            form: {
                type: 0,//0普通单张 1多订单合一
                sellerid: "",
                sourceid: "",
                status: "",
                invoicing_status:[],//开票状态
                buyername: "",//买家昵称
                invoicing_number:"",//税号
                invoice_header:"",//抬头
                kai_createtime: []
            },

            drawerTableHeight: window.innerHeight - 150+"px",
            detailVisible: false,
            detail: {},
            detailLog: [],

            commandType: "",
            commandTitle: "",
            detailNewVisible: false,
            detailNew: {},//新开票信息

            chsqForm: {}, //冲红申请
            chsqVisible: false,
            saveLoading: false,
            rules: {
                invoice_header: [
                    { required: true,trigger: 'blur'},
                ],
                email: [
                    { required: true,trigger: 'blur'}
                ],
                invoicing_number: [
                    { required: true,trigger: 'blur'}
                ],
            },

            moreSelectData: [],
            moreVisible: false,

            kpsqForm: {},
            kpsqVisible: false,//申请多合一开票

            stepLoading: false,
            step: 1,//下一步
        }
    },
    computed:{
        amountTotal(){
            let orderDetail = [];
            let amountTotal = 0;
            if(this.detailNew.order_detail){
                orderDetail = this.detailNew.order_detail;
            }else if(this.chsqForm.order_detail){
                orderDetail = this.chsqForm.order_detail;
            }else if(this.kpsqForm.order_detail){
                orderDetail = this.kpsqForm.order_detail;
            }
            orderDetail.forEach(item =>{
                amountTotal += Number(item.pay_amount);
            });
            return amountTotal.toFixed(2);
        },
    },
    filters: {
        filterShop(val, shops) {
            let label = val;
            shops.forEach(item=>{
                if(item.sellerid == val){
                    label = item.sellertitle;
                }
            });
            return label;
        },
    },
    created() {
        this.user = this.$store.getters.user;
        this.nodeActions = this.user.node_actions[this.$route.meta.id] ? this.user.node_actions[this.$route.meta.id] : [];
    },
    watch:{
        'form.type': {
            handler: function (newVal, oldVal) {
                this.searchBtn();
            },
            // 深度监听
            deep: true
        }
    },
    methods: {
        //搜索按钮
        searchBtn() {
            this.page = 1;
            this.getData();
        },
        //翻页
        pageChange(page) {
            this.page = page;
            this.getData();
        },
        //获取数据
        getData() {
            let param = {
                page: this.page,
                limit: this.limit
            };
            param = Object.assign(param, this.form);
            this.loading = true;
            invoiceList(param).then((res) => {
                this.loading = false;
                this.total = res.data.total;
                this.data = res.data.data;
            }).catch(() => {
                this.loading = false;
            });
        },
        //获取店铺
        getShop(){
            invoiceShops().then((res) =>{
                this.shops = res.data;
            })
        },
        //获取详情
        detailBtn(sourceId){
            this.loading = true;
            invoiceDetail({sourceId: sourceId}).then((res) =>{
                this.loading = false;
                this.detail = res.data.detail;
                this.detailLog = res.data.detail_log;
                this.detailVisible = true;
            }).catch(()=>{
                this.loading = false;
            })
        },
        //更多操作
        actionBtn(command, row) {
            this.commandType = command;
            switch (command) {
                case "CHSQ"://发起冲红申请
                    this.chsqForm = JSON.parse(JSON.stringify(row));
                    this.chsqVisible = true;
                    break;
                case "DOWN"://下载发票
                    if(!row.c_url){
                        this.$message.error("下载失败");return;
                    }
                    window.open(row.c_url, '_blank');
                    break;
                case "KP"://再次申请开票
                    this.commandTitle = "再次申请开票";
                    if (!row.invoice_headerid) {
                        row.invoice_headerid = "900";
                    }
                    this.detailNew = JSON.parse(JSON.stringify(row));
                    this.detailNewVisible = true;
                    break;
                case "EDIT"://修改信息
                    this.commandTitle = "修改信息";
                    if (!row.invoice_headerid) {
                        row.invoice_headerid = "900";
                    }
                    this.detailNew = JSON.parse(JSON.stringify(row));
                    this.detailNewVisible = true;
                    break;
                case "KPIF"://新开票信息
                    this.commandTitle = "新开票信息";
                    this.loading = true;
                    invoiceNewDetail({sourceId: row.sourceid}).then((res) =>{
                        this.loading = false;
                        if(res.data.sourceid){
                            this.detailNew = res.data;
                            this.detailNewVisible = true;
                        }else{
                            this.$message.error("获取信息失败");
                        }
                    }).catch(()=>{
                        this.loading = false;
                    })
                    break;

            }
        },
        //修改信息、再次申请开票
        updateBtn(){
            let orderDetail = [];
            this.detailNew.order_detail.forEach(item =>{
                orderDetail.push({
                    id: item.id,
                    num: item.num,
                    pay_amount: item.pay_amount || 0,
                })
            });
            let obj = {
                sourceIds: [this.detailNew.sourceid],
                type: this.commandType == 'KP' ? 1 : 0,
                invoice_headerid: this.detailNew.invoice_headerid,
                invoice_header: this.detailNew.invoice_header,
                email: this.detailNew.email,
                notes: this.detailNew.notes,
                order_detail: orderDetail,
                pay_amount: this.amountTotal,
            };
            if(!this.detailNew.sourceid){
                this.$message.warning("订单号缺失");return;
            }
            if(this.chsqForm.invoice_headerid == "900" && (!this.chsqForm.invoice_header || !this.chsqForm.email)){
                this.$message.warning("必填项不能为空");return;
            }
            if(this.chsqForm.invoice_headerid == "18661" && (!this.chsqForm.invoice_header || !this.chsqForm.email || !this.chsqForm.invoicing_number)){
                this.$message.warning("必填项不能为空");return;
            }
            if(this.chsqForm.invoice_headerid == "18661"){
                obj = Object.assign(obj, {
                    invoicing_number: this.detailNew.invoicing_number,
                    opening_bank: this.detailNew.opening_bank,
                    opening_bank_number: this.detailNew.opening_bank_number,
                    opening_bank_tel: this.detailNew.opening_bank_tel,
                    opening_bank_address: this.detailNew.opening_bank_address,
                });
            }
            this.saveLoading = true;
            invoiceSetData(obj).then((res) =>{
                this.saveLoading = false;
                if(res.code === 0){
                    this.$message.success("操作成功");
                    this.getData();
                    this.detailNewVisible = false;
                }else{
                    this.$message.error(res.msg);
                }
            }).catch(()=>{
                this.saveLoading = false;
            })
        },
        //冲红申请
        applyCHBtn(){
            let ch_status = this.chsqForm.hongchong_status;
            let obj = {ch_status: ch_status, sourceIds: [this.chsqForm.sourceid]};
            if(ch_status == 2){
                let order_detail = [];
                this.chsqForm.order_detail.forEach(item =>{
                    order_detail.push({
                        id: item.id,
                        sourceid: item.sourceid,
                        num: item.num || 0,
                        pay_amount: item.pay_amount || 0,
                    });
                });
                if (this.chsqForm.invoice_headerid == "900" && this.chsqForm.invoice_header && this.chsqForm.email) {
                    obj = {
                        ch_status: ch_status,
                        sourceIds: [this.chsqForm.sourceid],
                        invoice_headerid: this.chsqForm.invoice_headerid,
                        invoice_header: this.chsqForm.invoice_header,
                        email: this.chsqForm.email,
                        notes: this.chsqForm.notes,
                        order_detail: order_detail,
                        pay_amount: this.amountTotal,
                    };
                }else if (this.chsqForm.invoice_headerid == "18661" && this.chsqForm.invoicing_number && this.chsqForm.invoice_header && this.chsqForm.email) {
                    obj = {
                        ch_status: ch_status,
                        sourceIds: [this.chsqForm.sourceid],
                        invoice_headerid: this.chsqForm.invoice_headerid,
                        invoice_header: this.chsqForm.invoice_header,
                        email: this.chsqForm.email,
                        invoicing_number: this.chsqForm.invoicing_number,
                        opening_bank: this.chsqForm.opening_bank,
                        opening_bank_number: this.chsqForm.opening_bank_number,
                        opening_bank_tel: this.chsqForm.opening_bank_tel,
                        opening_bank_address: this.chsqForm.opening_bank_address,
                        notes: this.chsqForm.notes,
                        order_detail: order_detail,
                        pay_amount: this.amountTotal,
                    };
                }else{
                    this.$message.warning("必填项不能为空");
                    return;
                }
            }
            this.saveLoading = true;
            invoiceApplyCH(obj).then((res) =>{
                this.saveLoading = false;
                if(res.code === 0){
                    this.$message.success("申请发起成功");
                    this.getData();
                    this.chsqVisible = false;
                }else{
                    this.$message.error(res.msg);
                }
            }).catch(()=>{
                this.saveLoading = false;
            })
        },
        //关闭抽屉
        closeBtn(){
            this.detail = {};
            this.detailVisible = false;

            this.detailNew = {};
            this.detailNewVisible = false;

            this.kpsqForm = {};
            this.kpsqVisible = false;

            this.chsqForm = {};
            this.chsqVisible = false;
            this.moreVisible = false;

            this.step = 1;
            this.moreSelectData = [];
            this.commandType = "";
            this.commandTitle = "";
        },
        //打开多合一开票申请
        openKpsqBtn(){
            this.kpsqVisible = true;
        },
        //多开抽屉
        openMoreBtn(type, title){
            this.commandType = type;
            this.commandTitle = title;
            this.moreVisible = true;
        },
        moreSelectBtn(val){
            this.moreSelectData = val;
            console.log("多开", val);
        },
        //取消多合一 多开
        cancelMoreBtn(){
            this.saveLoading = true;
            invoiceCancelMore({merge_tags: this.moreSelectData}).then((res) =>{
                this.saveLoading = false;
                if(res.code === 0){
                    this.$message.success("取消成功");
                    this.getData();
                    this.closeBtn();
                }else{
                    this.$message.error(res.msg);
                }
            }).catch(() =>{
                this.saveLoading = false;
            })
        },
        //下一步 多开
        stepBtn(){
            this.stepLoading = true;
            let sourceIds = [];
            this.moreSelectData.forEach(item =>{
                sourceIds.push(item.sourceid)
            });
            invoiceCHDetail({sourceId: sourceIds}).then((res) =>{
                this.stepLoading = false;
                this.chsqForm = res.data;
                this.step = 0;
                this.chsqForm.sourceIds_dom = this.chsqForm.sourceIds.join("<br>");
            }).catch(()=>{
                this.stepLoading = false;
            })
        },
        //多合一开票申请
        kpsqStepBtn(){
            let form = {
                sourceIds: [],
                sourceIds_dom: "",
                order_detail: [],
                invoice_headerid: "900",
                invoice_header: this.moreSelectData[0].invoice_header,//随意填入
                email: this.moreSelectData[0].email,//随意填入
                invoicing_number: this.moreSelectData[0].invoicing_number,//随意填入
                opening_bank: "",
                opening_bank_number: "",
                opening_bank_address: "",
                opening_bank_tel: "",
                notes: "",
            }
            this.moreSelectData.forEach(item =>{
                form.sourceIds.push(item.sourceid);
                form.sourceIds_dom += item.sourceid+"<br>";
                form.order_detail.push(...item.order_detail);
            });
            this.kpsqForm = form;
            this.step = 0;
        },
        //提交按钮 多开
        moreSubmitBtn(){
            let orderDetail = [];
            this.chsqForm.order_detail.forEach(item =>{
                orderDetail.push({
                    id: item.id,
                    sourceid: item.sourceid,
                    num: item.num || 0,
                    pay_amount: item.pay_amount || 0,
                });
            });
            //再次申请开票
            if(this.commandType == 4){
                if(this.chsqForm.invoice_headerid == "900" && (!this.chsqForm.invoice_header || !this.chsqForm.email)){
                    this.$message.warning("必填项不能为空");return;
                }
                if(this.chsqForm.invoice_headerid == "18661" && (!this.chsqForm.invoice_header || !this.chsqForm.email || !this.chsqForm.invoicing_number)){
                    this.$message.warning("必填项不能为空");return;
                }
                let obj = {
                    sourceIds: this.chsqForm.sourceIds,
                    type: 1,
                    invoice_headerid: this.chsqForm.invoice_headerid,
                    invoice_header: this.chsqForm.invoice_header,
                    email: this.chsqForm.email,
                    notes: this.chsqForm.notes,
                    order_detail: orderDetail,
                    pay_amount: this.amountTotal,
                };
                if(this.chsqForm.invoice_headerid == "18661") {
                    obj = Object.assign(obj, {
                        invoicing_number: this.chsqForm.invoicing_number,
                        opening_bank: this.chsqForm.opening_bank,
                        opening_bank_number: this.chsqForm.opening_bank_number,
                        opening_bank_tel: this.chsqForm.opening_bank_tel,
                        opening_bank_address: this.chsqForm.opening_bank_address,
                    });
                }
                this.saveLoading = true;
                invoiceSetData(obj).then((res) =>{
                    this.saveLoading = false;
                    if(res.code === 0){
                        this.$message.success("操作成功");
                        this.getData();
                        this.closeBtn();
                    }else{
                        this.$message.error(res.msg);
                    }
                }).catch(()=>{
                    this.saveLoading = false;
                })
            }
            //发起冲红申请
            if(this.commandType == 2){
                let ch_status = this.chsqForm.hongchong_status;
                let obj = {ch_status: ch_status, sourceIds: this.chsqForm.sourceIds};
                if(ch_status == 2){
                    if(this.chsqForm.invoice_headerid == "900" && (!this.chsqForm.invoice_header || !this.chsqForm.email)){
                        this.$message.warning("必填项不能为空");return;
                    }
                    if(this.chsqForm.invoice_headerid == "18661" && (!this.chsqForm.invoice_header || !this.chsqForm.email || !this.chsqForm.invoicing_number)){
                        this.$message.warning("必填项不能为空");return;
                    }
                    obj = {
                        ch_status: ch_status,
                        sourceIds: this.chsqForm.sourceIds,
                        invoice_headerid: this.chsqForm.invoice_headerid,
                        invoice_header: this.chsqForm.invoice_header,
                        email: this.chsqForm.email,
                        notes: this.chsqForm.notes,
                        order_detail: orderDetail,
                        pay_amount: this.amountTotal,
                    };
                    if(this.chsqForm.invoice_headerid == "18661") {
                        obj = Object.assign(obj, {
                            invoicing_number: this.chsqForm.invoicing_number,
                            opening_bank: this.chsqForm.opening_bank,
                            opening_bank_number: this.chsqForm.opening_bank_number,
                            opening_bank_tel: this.chsqForm.opening_bank_tel,
                            opening_bank_address: this.chsqForm.opening_bank_address,
                        });
                    }
                }
                this.saveLoading = true;
                invoiceApplyCH(obj).then((res) =>{
                    this.saveLoading = false;
                    if(res.code === 0){
                        this.$message.success("申请发起成功");
                        this.getData();
                        this.closeBtn();
                    }else{
                        this.$message.error(res.msg);
                    }
                }).catch(()=>{
                    this.saveLoading = false;
                })
            }
            //修改开票信息
            if(this.commandType == 1){
                if(this.chsqForm.invoice_headerid == "900" && (!this.chsqForm.invoice_header || !this.chsqForm.email)){
                    this.$message.warning("必填项不能为空");return;
                }
                if(this.chsqForm.invoice_headerid == "18661" && (!this.chsqForm.invoice_header || !this.chsqForm.email || !this.chsqForm.invoicing_number)){
                    this.$message.warning("必填项不能为空");return;
                }
                let obj = {
                    sourceIds: this.chsqForm.sourceIds,
                    type: 2,
                    invoice_headerid: this.chsqForm.invoice_headerid,
                    invoice_header: this.chsqForm.invoice_header,
                    email: this.chsqForm.email,
                    notes: this.chsqForm.notes,
                    order_detail: orderDetail,
                    pay_amount: this.amountTotal,
                };
                if(this.chsqForm.invoice_headerid == "18661") {
                    obj = Object.assign(obj, {
                        invoicing_number: this.chsqForm.invoicing_number,
                        opening_bank: this.chsqForm.opening_bank,
                        opening_bank_number: this.chsqForm.opening_bank_number,
                        opening_bank_tel: this.chsqForm.opening_bank_tel,
                        opening_bank_address: this.chsqForm.opening_bank_address,
                    });
                }
                this.saveLoading = true;
                invoiceSetMoreData(obj).then((res) =>{
                    this.saveLoading = false;
                    if(res.code === 0){
                        this.$message.success("修改开票信息成功");
                        this.getData();
                        this.closeBtn();
                    }else{
                        this.$message.error(res.msg);
                    }
                }).catch(()=>{
                    this.saveLoading = false;
                })
            }
        },
        kpsqSubmitBtn(){
            let orderDetail = [];
            this.kpsqForm.order_detail.forEach(item =>{
                orderDetail.push({
                    id: item.id,
                    sourceid: item.sourceid,
                    num: item.num || 0,
                    pay_amount: item.pay_amount || 0,
                });
            });
            if(this.kpsqForm.invoice_headerid == "900" && (!this.kpsqForm.invoice_header || !this.kpsqForm.email)){
                this.$message.warning("必填项不能为空");return;
            }
            if(this.kpsqForm.invoice_headerid == "18661" && (!this.kpsqForm.invoice_header || !this.kpsqForm.email || !this.kpsqForm.invoicing_number)){
                this.$message.warning("必填项不能为空");return;
            }
            let obj = {
                sourceIds: this.kpsqForm.sourceIds,
                type: 1,
                invoice_headerid: this.kpsqForm.invoice_headerid,
                invoice_header: this.kpsqForm.invoice_header,
                email: this.kpsqForm.email,
                notes: this.kpsqForm.notes,
                order_detail: orderDetail,
                pay_amount: this.amountTotal,
            };
            if(this.kpsqForm.invoice_headerid == "18661") {
                obj = Object.assign(obj, {
                    invoicing_number: this.kpsqForm.invoicing_number,
                    opening_bank: this.kpsqForm.opening_bank,
                    opening_bank_number: this.kpsqForm.opening_bank_number,
                    opening_bank_tel: this.kpsqForm.opening_bank_tel,
                    opening_bank_address: this.kpsqForm.opening_bank_address,
                });
            }
            this.saveLoading = true;
            invoiceSetMoreData(obj).then((res) =>{
                this.saveLoading = false;
                if(res.code === 0){
                    this.$message.success("修改开票信息成功");
                    this.getData();
                    this.closeBtn();
                }else{
                    this.$message.error(res.msg);
                }
            }).catch(()=>{
                this.saveLoading = false;
            })
        },
    },
    mounted() {
        this.getShop();
        this.searchBtn();
    }
}
</script>

<style scoped>
    .detail_con{
        width: 150px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }
    .detail_ch_con{
        width: 250px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }

</style>
